//
// Created by dragon on 23-8-11.
//

#ifndef __OS_MESSAGE_H__
#define __OS_MESSAGE_H__

#include <asm/type.h>
#include <macros.h>

typedef struct vbe_mode_info {
    u16_t attributes;  // deprecated, only bit 7 should be of interest to you, and it indicates the mode supports a linear frame buffer.
    u8_t window_a;     // deprecated
    u8_t window_b;     // deprecated
    u16_t granularity; // deprecated; used while calculating bank numbers
    u16_t window_size;
    u16_t segment_a;
    u16_t segment_b;
    u32_t win_func_ptr; // deprecated; used to switch banks from protected mode without returning to real mode
    u16_t pitch;        // number of bytes per horizontal line
    u16_t width;        // width in pixels
    u16_t height;       // height in pixels
    u8_t w_char;        // unused...
    u8_t y_char;        // ...
    u8_t planes;
    u8_t bpp;   // bits per pixel in this mode
    u8_t banks; // deprecated; total number of banks in this mode
    u8_t memory_model;
    u8_t bank_size; // deprecated; size of a bank, almost always 64 KB but may be 16 KB...
    u8_t image_pages;
    u8_t reserved0;
    u8_t red_mask;
    u8_t red_position;
    u8_t green_mask;
    u8_t green_position;
    u8_t blue_mask;
    u8_t blue_position;
    u8_t reserved_mask;
    u8_t reserved_position;
    u8_t direct_color_attributes;
    u32_t framebuffer; // physical address of the linear frame buffer; write here to draw to the screen
    u32_t off_screen_mem_off;
    u16_t off_screen_mem_size; // size of memory in the framebuffer but not being displayed on the screen
    u8_t reserved1[206];
} __attribute__((packed)) vbe_mode_info_t;

typedef struct message {
    u64_t addr;
    i32_t width;
    i32_t height;
    i32_t pitch;
    i32_t bpp;
    i32_t x;
    i32_t y;
    u32_t fg;
    u32_t bg;
} message_t;

extern void shows(const i8_t *msg, i32_t len);
extern int init_draw(u32_t fg, u32_t bg);
//extern void showc(u64_t fb, u32_t pitch, u32_t bpp, u32_t x, u32_t y, u32_t fg, u32_t bg, u8_t c);
extern void showc(message_t *vbe, u8_t c);

extern void draw_rect(u32_t color, u8_t x, u8_t y, u8_t w, u8_t h);
extern message_t __msg;
extern vbe_mode_info_t __vbe_info;
#endif // OS_MESSAGE_H
